From: Paul Eggert Date: Tue, 5 Apr 2011 20:22:53 +0000 (-0700) Subject: * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~324^2~4204^2~5 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=54a01cef4eeab63e6fd39a4a62c74c41e077900e;p=emacs.git * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior by passing a long int to a printf format expecting an int. --- diff --git a/src/ChangeLog b/src/ChangeLog index f65c528b3a2..a822b31f688 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,9 @@ Fix more problems found by GCC 4.6.0's static checks. + * fns.c (Fstring_to_unibyte): Don't rely on undefined behavior + by passing a long int to a printf format expecting an int. + * lisp.h (message, message_nolog, doprint, error, verror, fatal): Mark as printf-like functions. diff --git a/src/fns.c b/src/fns.c index c45d9e31ef2..ca18dbfc100 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1076,7 +1076,10 @@ an error is signaled. */) EMACS_INT converted = str_to_unibyte (SDATA (string), str, chars, 0); if (converted < chars) - error ("Can't convert the %dth character to unibyte", converted); + { + long lconverted = converted; + error ("Can't convert the %ldth character to unibyte", lconverted); + } string = make_unibyte_string ((char *) str, chars); xfree (str); }